package com.example.app.pages.main.home.addNew.addRecord

import android.util.Log
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.width
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
import com.example.app.components.MyPlaceSelected.MyMapSelected

@Composable
fun PlaceSearch(showBool: Boolean = false) {
    var density = LocalDensity.current.density
    var windowWidth = with(density) {
        LocalConfiguration.current.screenWidthDp
    }
    var offsetX = animateDpAsState(targetValue = if (showBool) 0.dp else -windowWidth.dp)
    var alpha = animateFloatAsState(targetValue = if (showBool) 1f else 0f)
    if (offsetX.value > -windowWidth.dp) {
        Box(
            modifier = Modifier
                .width(windowWidth.dp)
                .offset(x = offsetX.value)
                .alpha(alpha.value)
                .background(MaterialTheme.colorScheme.surface)
        ) {
            MyMapSelected(
                emitsFromMyMapSelected = { latLng, title ->

                }
            )
        }
    }
}